const fs = require('fs')
// 创建一个可读流
const readStream = fs.createReadStream(
  './example.txt',
  'utf8'
)

// 创建一个写入流
const writeStream = fs.createWriteStream(
  './example2.txt',
)

// 监听readStream的data事件，当有数据可读时触发
readStream.on('data', (chunk) => {
  console.log(chunk);
  // 向可写流中写入数据块
  writeStream.write(chunk)
})
